// pages/login/login.js

const {Http} =require("../../utils/http")
const { debounce } = require('../../utils/util')
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(Http)
  },

  tologin(){
    // console.log(Login.login())
    wx.getUserProfile({
      desc: 'desc',
      success(res) {
        console.log(res)
        wx.login({
          success(res){
            console.log(res,'000')
            Http('/login?grant_type=mini_app',{
              principal: res.code
            },"POST",(res)=>{
              console.log(res)
              // const {}
              if(res.statusCode){
                wx.switchTab({
                  url: '/pages/index/index',
                })
              }
              wx.setStorageSync('token', res.data.access_token)
            })
          }
        })
      }
    })
  }

})